class Solution:
    def isLongPressedName(self, name: str, typed: str) -> bool:
        n=0
        t=0
        while n<len(name):
            if t==len(typed):
                return False
            if name[n]==typed[t]:
                n+=1
                t+=1
            else:
                if n==0:
                    return False
                if typed[t]==name[n-1]:
                    t+=1
                else:
                    return False
        while t<len(typed):
            if typed[t]!=name[-1]:
                return False
            t+=1
        return True